# 测试文件类型API的简化脚本
$apiUrl = "http://localhost:5269/api/file/types"

Write-Host "调用API: $apiUrl"

try {
    # 使用Invoke-RestMethod调用API
    $response = Invoke-RestMethod -Uri $apiUrl -Method Get
    
    Write-Host "\nAPI调用成功!"
    Write-Host "返回的文件类型数量: $($response.Length)"
    
    # 显示每个文件类型的属性名和值
    Write-Host "\n文件类型数据结构:"
    if ($response.Length -gt 0) {
        $firstItem = $response[0]
        Write-Host "属性列表: $(($firstItem | Get-Member -MemberType NoteProperty).Name -join ', ')"
        
        Write-Host "\n第一个文件类型的详细信息:"
        $firstItem | Format-List
        
        # 显示所有文件类型的TypeName
        Write-Host "\n所有文件类型的TypeName:"
        foreach ($item in $response) {
            Write-Host "- $($item.typeName)"
        }
    }
    
    # 保存原始JSON响应到文件，便于查看
    $response | ConvertTo-Json | Out-File -FilePath "d:\Code\DXApplications\FileTypeResponse.json" -Encoding utf8
    Write-Host "\n原始JSON响应已保存到 FileTypeResponse.json"
} catch {
    Write-Host "\nAPI调用失败:"
    Write-Host "错误信息: $($_.Exception.Message)"
}